import React from 'react'
// ===================================================================== declare
const { $Lazy } = window
// ===================================================================== private component
const Page 			= $Lazy.load(()=>import('#tp/page/page-container'))
const Detailtable 	= $Lazy.state(()=>import('./cpt/detail-table'))
const EnterCodeList 	= $Lazy.state(()=>import('./cpt/enter-code-list'))
const PutawaySpecList 	= $Lazy.state(()=>import('./cpt/putaway-spec-list'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		
	}
	
	render(){
		const isAkey = window.location.hash.indexOf('a-key-putaway') >= 0
		return (
			<>	
				{
					isAkey ? (
						<Page nobc title='一键上架' controls={this.state.controls?.()} >
							{/* Form */}
							<section className='ex fx'>
								<div className='h ex fv bcf mr5' style={{width:'50%'}}>
									<PutawaySpecList onRef={ ref => this.putawaySpecListRef = ref } 
										onRefresh = {({sf_number,project_name})=>this.enterCodeListRef.onrowTable({sf_number,project_name})} 
									/>
								</div>
								<div className=' h ex fv bcf' style={{width:'50%'}} >
									<EnterCodeList 
										isSpec			= {false}
										onRef			= { ref => {
											this.enterCodeListRef = ref
											this.setState({ controls: ref.controls })
										} } 
										onRefresh={()=>this.putawaySpecListRef.fetch({})}
									/>
								</div>
							</section>
						</Page>
					) : (
						<Page nobc title='标本上架' controls={this.state.controls?.()}>
							{/* Form */}
							<section className='ex fx '>
								<div className='h ex fv bcf mr5 ' style={{width:'50%'}}>
									<PutawaySpecList onRef={ ref => this.putawaySpecListRef = ref }  
										onRefresh={( {sf_number, project_name} ) => {
											this.enterCodeListRef.onrowTable({sf_number, project_name})}
										}
									/>
									{/* 子表格 */}
									<Detailtable onRef={ ref => this.tableRef = ref }  />
								</div>
								<div className=' h ex fv bcf' style={{width:'50%'}}  >
									<EnterCodeList
										isSpec			= {true}
										onRef			= { ref => {
											this.enterCodeListRef = ref
											this.setState({ controls: ref.controls })
										} } 
										getAlertList	= { data => this.tableRef.setState({ data }) }
										onRefresh={()=>this.putawaySpecListRef.fetch()}
									/>
								</div>
							</section>
						</Page>
					)
				}
			</>
		)
	}
}

export default Index